package com.jdcjk.base.presenter;

import android.content.Context;

import com.google.gson.Gson;
import com.jdcjk.base.model.BaseModel;
import com.mvp.presenter.impl.MvpBasePresenter;

import okhttp3.Call;
import okhttp3.Request;

/**
 * Created by dong on 2016/12/1.
 * 中介基础实现类
 */

public abstract class BasePresenter<M extends BaseModel> extends MvpBasePresenter {

    private Context context;
    private Gson gson;
    private M model;

    public BasePresenter(Context context) {
        this.context = context;
        this.gson = new Gson();
        this.model = bindModel();
    }

    public Context getContext() {
        return context;
    }

    public Gson getGson() {
        return gson;
    }

    public M getModel() {
        return model;
    }

    public abstract M bindModel();

    public interface OnUIThreadListener<T> {
        void onBefore(Request request, int id);

        void onAfter(int id);

        void onError(Call call, Exception e, int i);

        void onResponse(T result);
    }

}
